package com.mvc4g.example.mockup.client.action;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.mvc4g.client.ActionInterface;
import com.mvc4g.client.Controller;
import com.mvc4g.example.mockup.client.Constants;
import com.mvc4g.example.mockup.client.MockUpService;
import com.mvc4g.example.mockup.client.MockUpServiceAsync;
import com.mvc4g.example.mockup.client.bean.AboutBean;
import com.mvc4g.example.mockup.client.view.templates.RootTemplate;
import com.mvc4g.example.mockup.client.view.views.AboutView;

public class GoToAboutPageAction implements ActionInterface, Constants {

	private static MockUpServiceAsync services = MockUpService.Util
			.getInstance();

	@Override
	public void execute(final Controller controller, Object form) {
		services.getAbout(new AsyncCallback<AboutBean>() {

			@Override
			public void onFailure(Throwable caught) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onSuccess(AboutBean result) {
				AboutView aboutView = (AboutView) controller
						.getView(ABOUT_VIEW);

				RootTemplate rootView = (RootTemplate) controller
						.getView(ROOT_TEMPLATE);
				rootView.changePage(aboutView, GO_TO_ABOUT_PAGE);

				aboutView.setContent(result);

			}

		});

	}

}
